package com.LeeCode;

/**
 * 检查是否区域内所有整数都被覆盖
 */

public class Code1893 {
    public static void main(String[] args) {

    }

    public boolean isCovered(int[][] ranges, int left, int right) {
        int[] diff = new int[52];
        for (int[] range : ranges) {
            int start = range[0], end = range[1];
            diff[start]++;
            diff[end + 1]--;
        }

        int sum = 0;
        for (int i = 1; i <= right; i++) {
            sum += diff[i];
            if(i >= left && sum == 0) return false;
        }
        return true;
    }
}
